<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<p>1111</p>
		<p>2222</p>
		
		<div id="div1"></div>
		
		<script>
			//获取文档中的所有p节点
			var myNOdeList = document.querySelectorAll("p");
			//访问第二个p标签
			var y = myNOdeList[1];
			
			//NodeList 对象 length 属性
			document.getElementById("div1").innerHTML = myNOdeList.length;
			
			//修改所有p标签的背景颜色
			for(var i in myNOdeList){
				myNOdeList[i].style.backgroundColor = "red";
			}
		</script>
	</body>
</html>